package com.dxx.cloud.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dxx.cloud.admin.mapper.CustomerCartMapper;
import com.dxx.cloud.admin.module.entity.CustomerCart;
import com.dxx.cloud.admin.service.ICustomerCartService;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * <p>
 * 购物车 服务实现类
 * </p>
 *
 * @author dh
 * @since 2025-07-21
 */
@Service
public class CustomerCartServiceImpl extends ServiceImpl<CustomerCartMapper, CustomerCart> implements ICustomerCartService {

    @Override
    public boolean removeFromCart(Serializable id) {
        if(null == id) {
            return false;
        }
        return update(new LambdaUpdateWrapper<CustomerCart>().set(CustomerCart::getIsDeleted, 1).eq(CustomerCart::getId, id));
    }

    @Override
    public boolean updateBuyNumber(Serializable id, Integer buyNumber) {
        if(null == id) {
            return false;
        }
        return update(new LambdaUpdateWrapper<CustomerCart>().set(CustomerCart::getBuyNumber, buyNumber).eq(CustomerCart::getId, id));
    }
}
